<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\admin\controller;

/**
 * 公司控制器
 */
class Company extends AdminBase
{

    /**
     * 公司列表
     */
    public function companyList()
    {
        // var_dump($num[0]['count(id)']);exit;
        $list=$this->logicCompany->getCompanyList();
        foreach ($list as $key => $value) {
            $list[$key]['num']=$this->logicStaff->staffNum('company',$value['id'])['num'];
        }
        $this->assign('list', $list);
        return $this->fetch('company_list');
    }
    
    /**
     * 公司添加
     */
    public function companyAdd()
    {
        
        IS_POST && $this->jump($this->logicCompany->companyAdd($this->param));
        
        return $this->fetch('company_add');
    }
    
    /**
     * 公司编辑
     */
    public function companyEdit()
    {
        
        IS_POST && $this->jump($this->logicCompany->companyEdit($this->param));
        
        // var_dump($this->param);exit();
        $info = $this->logicCompany->getCompanyInfo(['id' => $this->param['id']]);
        
        $this->assign('info', $info);
        
        return $this->fetch('company_edit');
    }
    
    /**
     * 会员删除
     */
    public function companyDel($id = 0)
    {
        
        return $this->jump($this->logicCompany->companyDel(['id' => $id]));
    }
}
